package com.qztc.hire_end_core.controller;

import com.qztc.hire_end_dto.dto.Carousel;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/carousel")
@Tag(name = "汉服轮播图管理接口")
public class CarouselController {

    @Operation(summary = "查询所有轮播图")
    @GetMapping("/get")
    public List<Carousel> getCarousel() {
        return new Carousel().selectAll();
    }

    @Operation(summary = "根据carouselId获取具体轮播图")
    @GetMapping("/getbycarouselId")
    public Carousel getbycarouselId(@RequestParam Integer carouselId) {
        return new Carousel().selectById(carouselId);
    }

    @Operation(summary = "根据carouselId删除某一个具体轮播图")
    @DeleteMapping("/delete")
    public boolean delete(@RequestBody Carousel carousel) {
        return carousel.deleteById(carousel.getCarouselId());
    }

    @Operation(summary = "根据carouselId修改某一个具体轮播图")
    @PutMapping("/update")
    public boolean update(@RequestBody Carousel carousel) {
        return carousel.updateById();
    }

    @Operation(summary = "增加轮播图")
    @PostMapping("/add")
    public boolean add(@RequestBody Carousel carousel) {
        return carousel.insert();
    }
}
